<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js" type="text/javascript"></script>
</head>
<body>
    <!--  -->
    <div id="app">
        <cpn1></cpn1>
        <cpn1></cpn1>
        <cpn1></cpn1>
    </div>
    <!--  -->
    <template id="cpn">
        <div>
            <p>当前计数：{{counter}}</p>
            <button @click="increment">+</button>
            <button @click="decrement">-</button>
        </div>
    </template>
    <script>
        // 
        Vue.component("cpn1", {
            template: '#cpn',
            data(){ // 必须是函数
                return {
                    counter: 0
                }
            },
            methods: { // 
                increment(){
                    this.counter++;
                },
                decrement(){
                    this.counter--;
                }
            }
        });
        // 
        var app = new Vue({
            el: "#app",
            data: {
                message: "hello"
            }
        });
    </script>
</body>
</html>